package com.cloudbroker.bcs.platform.ltb.middle.bizservice.impl;

import com.cloudbroker.bcs.common.util.VOUtil;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.banner.BannerBizService;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.banner.back.BannerListData;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.banner.back.BannerListResult;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.banner.vo.BannerListForm;
import com.cloudbroker.bcs.platform.ltb.middle.entity.Banner;
import com.cloudbroker.bcs.platform.ltb.middle.service.BannerService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by daibd19671 on 2016/12/20.
 */
@Service
public class BannerBizServiceImpl implements BannerBizService{

    @Resource
    private BannerService bannerService;
    @Override
    public BannerListResult banner_list(BannerListForm form) {
        Banner banner = new Banner();
        banner.setCompany_id(form.getCompany_id());
        List<Banner> list = bannerService.list(banner);
        List<BannerListData> backList = new ArrayList<>(list.size());
        for(Banner b : list){
            BannerListData bannerListData = new BannerListData();
            BeanUtils.copyProperties(b,bannerListData);
            backList.add(bannerListData);
        }
        BannerListResult back = new BannerListResult();
        back.setData_list(backList);
        return VOUtil.setSuccessResult(back);
    }
}
